package com.lifeng.controller;

import com.github.pagehelper.PageHelper;
import com.lifeng.domain.OrderBean;
import com.lifeng.service.OrderService;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * Created by lifeng on 2019/4/30.
 */
@RestController
@RequestMapping("/order")
public class OrderController {
    @Resource
    private OrderService orderService;

    @RequestMapping("/save")
    @ResponseBody
    public Object save(OrderBean orderBean){
        return orderService.insert(orderBean);
    }

    @RequestMapping("/delete")
    @ResponseBody
    public Object delete(OrderBean orderBean){
        return orderService.delete(orderBean);
    }

    @RequestMapping(value = "/{orderNo}",produces={"application/json; charset=UTF-8"})
    @ResponseBody
    public Object findByOrderNo(@PathVariable("orderNo") Long orderNo){
        return orderService.selectByOrderNo(orderNo);
    }

    @RequestMapping(value = "/page",produces={"application/json; charset=UTF-8"})
    @ResponseBody
    public Object findForPage(OrderBean orderBean,Integer pagenum,Integer size){
        PageHelper.startPage(pagenum, size);
        return orderService.selectListForPage(orderBean);
    }
}
